package com.zhuzi.batch.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.core.JmsOperations;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhuzi
 * 2023/12/27 20:05
 */
@Slf4j
@RestController
@RequestMapping("/MQ")
public class MQMessageController {

    @Value("${ibm.mq.queueReceive}")
    private String destinationName;

    @Autowired
    private JmsOperations jmsOperations;
    @PostMapping("send")
    public String sendMQ(@RequestBody String message) throws Exception {
        //log.info("----生产MQ消息：{}-----",message);
        //System.out.println("超时时间"+((JmsTemplate)jmsOperations).getReceiveTimeout());
        jmsOperations.convertAndSend(destinationName, message);
        return "发送成功";
    }
}
